package com.spring.student.systemDB.dao;

import com.spring.student.systemDB.bean.Courses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public class ConursesDaoImpl implements IConursesDao{

    @Autowired
    JdbcTemplate jdbcTemplate;
    @Override
    public List<Courses> selectAll() {
        String sql = "select * from courses";
        List<Courses> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<Courses>(Courses.class));
        return query;
    }

    @Override
    public int updateCourse(Integer moive) {
        String sql = "update courses set moive = ? where moive = ?";
        int update = jdbcTemplate.update(sql, moive, moive);
        return update;
    }
}
